package com.letoken.platform.repo.admin.manager;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.pub.constant.LetokenTokenConstant;
import com.letoken.platform.repo.admin.dao.AdminSwapConfigMapper;
import com.letoken.platform.repo.admin.po.AdminSwapConfig;
import com.letoken.platform.repo.app.res.config.QuerySwapConfigRes;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author letokenlabs
 * @date 2022/11/24$
 */
@Log4j2
@Repository
public class AdminSwapConfigManager {

    @Autowired
    private AdminSwapConfigMapper adminSwapConfigMapper;


    /**
     * 查询let币价格
     *
     * @return
     */
    public AdminSwapConfig querySwapPrice(Integer tokenId) {
        LambdaQueryWrapper<AdminSwapConfig> query = Wrappers.lambdaQuery();
        query.eq(AdminSwapConfig::getTokenId, tokenId);
        return adminSwapConfigMapper.selectOne(query);
    }

    /**
     * 查询闪兑配置
     *
     * @return
     */
    public List<QuerySwapConfigRes> querySwapConfig() {
        return adminSwapConfigMapper.querySwapConfig();
    }

    /**
     * 查询闪兑配置
     *
     * @return
     */
    public QuerySwapConfigRes querySwapConfigByTokenId(Integer tokenId) {
        return adminSwapConfigMapper.querySwapConfigByTokenId(tokenId);
    }
}
